/**
 * @author: lk
 * @data: 2021/11/10 18:07
 */
package LeetCode;

/**
 * 提莫攻击XD
 */
public class _495 {
    public static void main(String[] args) {
        int  x = 0;
        int [] arr={1,2};
        x = new _495().findPoisonedDuration(arr, 2);
        int y=0;
    }
    public int findPoisonedDuration(int[] timeSeries, int duration) {
        return helper(timeSeries, duration, 0, timeSeries.length - 1);

    }

    private int helper(int[] timeSeries, int duration, int l, int h) {
        if(timeSeries == null || h < l)
            return 0;
        if(h==l)
            return duration;
        int res = helper(timeSeries, duration, l + 1, h);
        int x = Math.min(timeSeries[l + 1] - timeSeries[l],duration);
        return x+res;
    }
}
